/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-04-09
 * Time: 9:11
 */
public class Test3 {
   public static void selectionSort(double[] arr){
       for (int i = arr.length-1; i >= 0 ; i--) {
           double currentMax = arr[i];
           int currentMaxIndex = i;
           for (int j = i -1 ; j >= 0 ; j--) {
               if(currentMax < arr[j]){
                   currentMax = arr[j];
                   currentMaxIndex = j;
               }
           }
           if(currentMaxIndex != i){
               arr[currentMaxIndex] = arr[i];
               arr[i] = currentMax;
           }
       }
   }

    public static void main(String[] args) {
        double[] arr = new double[]{23.5, 3.4, 678.2, 54.3, 77.5, 432.6, 1.4, 6.8, 8.5};
        selectionSort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
